package com.yixiu.study.juc.taobao.num3;

import java.util.concurrent.locks.LockSupport;

/**
 * @CalssName T01_LockSupport
 * @Description 两个字符串 1 到 26； a到z ；循环轮流打印
 * @Author yixiu
 * @Date 2021/6/29 10:02
 * @Verison 1.0
 **/
public class T01_LockSupport {

    static Thread t1 = null, t2 = null;

    public static void main(String[] args) {
        char[] aI = "1234567".toCharArray();
        char[] aC = "ABCDEFG".toCharArray();

        t1 = new Thread(() -> {
            for (char c : aI){
                System.out.println(c);
                LockSupport.unpark(t2);
                LockSupport.park();
            }
        }, "t1");

        t2 = new Thread(() -> {
            for (char c : aC){
                LockSupport.park();
                System.out.println(c);
                LockSupport.unpark(t1);
            }
        }, "t2");


        t1.start();
        t2.start();

    }

}
